<?php

namespace App\Http\Controllers\Api\V2;

use App\Services\Gallery\Interfaces\DesignerServiceInterface;
use App\Services\Gallery\Model\Designer;
use App\Services\Gallery\Services\DesignerService;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;

class DesignerController extends BaseController
{
    /**
     * @var DesignerService
     */
    protected $designerService;

    public function __construct(DesignerServiceInterface $designerService)
    {
        $this->designerService = $designerService;
    }

    public function index(Request $request)
    {
        $designers = $this->designerService->index($request->all());
        $data = arr2_clear($designers["data"], ["id","name", "thumb", "job_name", "good_style", 'awards','design_idea','work_room']);
        foreach($data as $key=>$item){
            $classicCase = $this->designerService->getClass($item['id']);
            $classicCase = arr2_clear($classicCase, ["id", "title", "thumb",  "view_count", "sort", "type"]);
            $data[$key]['classicCase'] = $classicCase;
        }
        $designers['data'] = $data;
        return $this->data($designers);
    }

    public function detail($id)
    {
        $designer = $this->designerService->get($id);
        $designer = arr1_clear($designer, ["id","name", "thumb", "job_name", "good_style", 'awards','design_idea','work_room']);
        $classicCase = $this->designerService->getClass($id);
        $classicCase = arr2_clear($classicCase, ["id", "title", "thumb",  "view_count", "sort", "type"]);
        $designer['classicCase'] = $classicCase;
        return $this->data($designer);
    }

    

}
